﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Mbs.Collections
{
    public static class DictionaryExtensions
    {
        public static T GetValue<K, V, T>(this IDictionary<K, V> dic, K key, T defaultValue)
            where T : class
        {
            if (dic.ContainsKey(key) && dic[key] is T)
            {
                return dic[key] as T;
            }
            return defaultValue;
        }

        public static T GetValue<V, T>(this IDictionary<string, V> dic, string key, T defaultValue) where T : class
        {
            if (dic.ContainsKey(key) && dic[key] is T)
            {
                return dic[key] as T;
            }
            return defaultValue;
        }

    }
}
